#pragma once
#include"preCmpH.h"
#include"UIFontChar.h"
#include"UIFont.h"

BEGIN_NAMESPACE(ui_manager)
class UIManager;
BEGIN_NAMESPACE(ui_fonts)

class UIFontManager;
typedef std::shared_ptr<UIFontManager> UIFontManagerPtr; //

class UIFontManager
{
public:
	UIFontManager();
	~UIFontManager();
	void StartUp(UIManager& manager);
	void ShutDown();
	static UIFontManager& getInstance();
	UIFont LoadFont(std::string path);
	UIFont GetDefault();
	void LoadText(UIFont font, std::string text);
	UISize GetTextSize()const{return text_size_;}
	UIFontChar GetChar(int index)const;
	bool isLoaded()const{return loaded_;}
	void Clear();
private:
	FT_Library ft_lib_;
	std::list<FT_Face> loaded_faces_;
	FT_Face default_;

	std::vector<FT_Glyph> glyphs_;
	std::vector<FT_Vector> pos_;
	std::vector<FT_BitmapGlyph> bitmaps_;
	int nr_glyphs_;
	bool loaded_;
	int font_h_;
	UISize text_size_;
};

END_NAMESPACE // ui fonts
END_NAMESPACE // ui manager